package com.ccjq.shosestore.web.controller.product;

import com.ccjq.shosestore.product.po.HomePo;
import com.ccjq.shosestore.product.service.impl.HomeServiceImpl;
import com.ccjq.shosestore.product.t_productPo.DetailsPo;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.util.List;

/**
 * 详情控制器
 */
public class DetailsServlet extends HttpServlet {
    protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        HomeServiceImpl hsi = new HomeServiceImpl();
        List<HomePo> homeList = hsi.selectAll();
        String product_id = request.getParameter("product_id");
        DetailsPo detailsPo = hsi.selectDatails(product_id);
        request.setAttribute("detailsPo",detailsPo);
        request.setAttribute("homeList",homeList);
        request.getRequestDispatcher("/WEB-INF/jsp/product/product_detail.jsp").forward(request,response);
    }

    protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
    this.doPost(request,response);
    }
}
